package com.ruoyi.yzchu.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yzchu.domain.YzcShop;
import com.ruoyi.yzchu.service.IYzcShopService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 店铺Controller
 * 
 * @author ruoyi
 * @date 2025-04-06
 */
@RestController
@RequestMapping("/system/shop")
public class YzcShopController extends BaseController
{
    @Autowired
    private IYzcShopService yzcShopService;

    /**
     * 查询店铺列表
     */
    @PreAuthorize("@ss.hasPermi('system:shop:list')")
    @GetMapping("/list")
    public TableDataInfo list(YzcShop yzcShop)
    {
        startPage();
        List<YzcShop> list = yzcShopService.selectYzcShopList(yzcShop);
        return getDataTable(list);
    }

    /**
     * 导出店铺列表
     */
    @PreAuthorize("@ss.hasPermi('system:shop:export')")
    @Log(title = "店铺", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YzcShop yzcShop)
    {
        List<YzcShop> list = yzcShopService.selectYzcShopList(yzcShop);
        ExcelUtil<YzcShop> util = new ExcelUtil<YzcShop>(YzcShop.class);
        util.exportExcel(response, list, "店铺数据");
    }

    /**
     * 获取店铺详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shop:query')")
    @GetMapping(value = "/{shopId}")
    public AjaxResult getInfo(@PathVariable("shopId") Long shopId)
    {
        return success(yzcShopService.selectYzcShopByShopId(shopId));
    }

    /**
     * 新增店铺
     */
    @PreAuthorize("@ss.hasPermi('system:shop:add')")
    @Log(title = "店铺", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YzcShop yzcShop)
    {
        return toAjax(yzcShopService.insertYzcShop(yzcShop));
    }

    /**
     * 修改店铺
     */
    @PreAuthorize("@ss.hasPermi('system:shop:edit')")
    @Log(title = "店铺", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YzcShop yzcShop)
    {
        return toAjax(yzcShopService.updateYzcShop(yzcShop));
    }

    /**
     * 删除店铺
     */
    @PreAuthorize("@ss.hasPermi('system:shop:remove')")
    @Log(title = "店铺", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shopIds}")
    public AjaxResult remove(@PathVariable Long[] shopIds)
    {
        return toAjax(yzcShopService.deleteYzcShopByShopIds(shopIds));
    }
}
